<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\campsite\Line as ModelLine;

/**
 * 路线接口
 */
class Line extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @Author LK
     * @ApiTitle (路线列表)
     * @ApiMethod (GET)
     * @ApiParams (name="keywords", type="string", required=true, sample="", description="关键字")
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':1,'msg':'返回成功'})
     */
    public function list()
    {
        $param = request()->param();
        extract($param);
        $model = new ModelLine();
        if (isset($keywords) && $keywords) {
            $model->whereLike('title', '%' . $keywords . '%');
        }
        $list = $model->order('id desc')->paginate();
        $this->success('请求成功', $list);
    }
    /**
     * @Author LK
     * @ApiTitle (路线详情)
     * @ApiMethod (GET)
     * @ApiParams (name="id", type="integer", required=true, sample="", description="ID")
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':1,'msg':'返回成功'})
     */
    public function info()
    {
        $param = request()->param();
        extract($param);
        if (!isset($id) || !$id) {
            $this->error('参数错误');
        }
        $data = ModelLine::get($id);
        $this->success('请求成功', $data);
    }
}
